Fix pci passthru in xend interface used by libvirt
authorJim Fehlig <jfehlig@novell.com>
Mon, 8 Nov 2010 16:24:22 +0000 (16:24 +0000)
committerJim Fehlig <jfehlig@novell.com>
Mon, 8 Nov 2010 16:24:22 +0000 (16:24 +0000)
commit0d849111924534fe280d7d9ab6c2bf97772c3daf
tree46d7551ba4415332f41685c8ecff49cd885f2f47
parent47a3fb9662188c9e2f02a8a428e5cc72ce3f451a
Fix pci passthru in xend interface used by libvirt

Attempting to define or create a domain whose XML config contains a
passthru PCI device fails with libvirt

xen84: # cat win2k8r2.xml
...
   <hostdev mode='subsystem' type='pci' managed='no'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
    </hostdev>
...

xen84: # virsh create ./win2k8r2.xml
error: Failed to create domain from ./win2k8r2.xml
error: POST operation failed: xend_post: error from xen daemon:
  (xend.err "Error creating domain: 'key'")

The PCI device config maintained by xend includes a 'key' field, which is
initialized by xm client when using that tool and traditional xen config
file.  libvirt, which uses xend's sexpr-over-http interface (is that the
proper name for that interface??), does not initialize this field - and
shouldn't be expected to do so IMO.  Clients should not be bothered with
xend's internal representation of a PCI device.

This patch populates the 'key' field within xend if it is uninitialized,
similar to current initialization of 'uuid' field.  The 'vdevfn' field
suffers a similar problem if not (optionally) specified by user.
AFAICT, the xm client initializes 'vdevfn' to 0x100 if not specified so
I've done the same here.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/python/xen/util/pci.py